package cn.daniel.commonutils.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @description  Swagger配置
 * @author Daniel_Li
 * @createtime 2020-12-29 17:50
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .apiInfo(apiInfo())
                .select()
                //在这配置要扫描的包，接口在哪个包就配置那一个包
                .apis(RequestHandlerSelectors.basePackage("cn.daniel"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Daniel_Li的闲置物品易购平台")
                .description("闲置物品易购平台接口")
                .termsOfServiceUrl("Daniel")
                .contact(new Contact("Daniel_Li","cn.daniel","2387599520@qq.com"))
                .version("1.0")
                .build();
    }

}
